package com.itouch.bracelet.activity;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.itouch.bracelet.R;
import com.itouch.bracelet.adapter.KnowledgeAdapter;
import com.itouch.bracelet.bean.Knowledge;
import com.itouch.bracelet.diseaseinfo.DiseaseInfoActivity;

/**
 * cocoaSJ
 */
public class KnowledgeActivity extends BaseActivity implements OnClickListener,
		OnItemClickListener {

	private static final String LOG_TAG = "KnowledgeActivity";
	
	private ListView listview;
	private List<Knowledge> list;
	private KnowledgeAdapter adapter;
	
	
	@Override
	protected int setContentViewById() {
		return R.layout.activity_knowledge;
	}

	@Override
	protected void initViews() {
		listview = (ListView) this.findViewById(
				R.id.listview);
		list = new ArrayList<Knowledge>();
		String[] k_id=getResources().getStringArray(R.array.knowledge_id);
		String[] k_string=getResources().getStringArray(R.array.knowledge_string);
		
		for(int i =0;i<k_id.length;i++){
			Knowledge k = new Knowledge();
			k.setId(k_id[i]);
			k.setTitle(k_string[i]);
			list.add(k);
		}
		
		adapter = new KnowledgeAdapter(this, list);
		listview.setAdapter(adapter);
		listview.setOnItemClickListener(this);
		
	}

	@Override
	protected void initData() {
	}
	

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		
		try {
			Knowledge k = list.get(arg2);
			Intent intent = new Intent(context, DiseaseInfoActivity.class);
			intent.putExtra("type", Integer.parseInt(k.getId()));
			intent.putExtra("label", k.getTitle());
			startActivity(intent);
			
			
		} catch (ArrayIndexOutOfBoundsException e) {

		}

	}


	@Override
	public void onClick(View arg0) {
		Intent it =null;
		switch (arg0.getId()) {
		

		default:
			break;
		}

	}



	

	
}